// https://umijs.org/config/
import { defineConfig } from 'umi';
import { join } from 'path';
import defaultSettings from './defaultSettings';
import proxy from './proxy';

const { REACT_APP_ENV } = process.env;

export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  layout: {
    // https://umijs.org/zh-CN/plugins/plugin-layout
    locale: true,
    siderWidth: 208,
    ...defaultSettings,
  },
  // https://umijs.org/zh-CN/plugins/plugin-locale
  locale: {
    // default zh-CN
    default: 'zh-CN',
    antd: true,
    // default true, when it is true, will use `navigator.language` overwrite default
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@ant-design/pro-layout/es/PageLoading',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      layout: false,
      routes: [
        {
          path: '/user/login',
          layout: false,
          name: 'login',
          component: './user/Login',
        },
        {
          path: '/user',
          redirect: '/user/login',
        },
        {
          name: 'register-result',
          icon: 'smile',
          path: '/user/register-result',
          component: './user/register-result',
        },
        {
          name: 'register',
          icon: 'smile',
          path: '/user/register',
          component: './user/register',
        },
        {
          component: '404',
        },
      ],
    },
    {
      path: '/welcome',
      name: 'welcome',
      icon: 'smile',
      component: './Welcome',
      access: 'canRoot',
    },
    {
      path: '/operations',
      name: 'operations',
      icon: 'profile',
      routes: [
        {
          path: '/operations',
          redirect: '/operations/live',
        },
        {
          name: 'live',
          icon: 'smile',
          path: '/operations/live',
          component: './operations/live/index',
        },
        {
          name: 'livedetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/operations/live-detail',
          parentKeys: ['/operations/live'],
          component: './operations/live/detail',
        },
        {
          name: 'speciallist',
          icon: 'smile',
          path: '/operations/special',
          component: './operations/special/index',
        },
        {
          name: 'specialdetail',
          icon: 'smile',
          hideInMenu: true,
          parentKeys: ['/operations/special'],
          path: '/operations/special-detail',
          component: './operations/special/detail',
        },
      ],
    },
    {
      path: '/doctor',
      name: 'doctor',
      icon: 'profile',
      routes: [
        {
          path: '/doctor',
          redirect: '/doctor/doctor-list',
        },
        {
          name: 'list',
          icon: 'smile',
          path: '/doctor/doctor-list',
          component: './doctor/index',
        },
        {
          name: 'detail',
          icon: 'smile',
          hideInMenu: true,
          path: '/doctor/doctor-detail',
          parentKeys: ['/doctor/doctor-list'],
          component: './doctor/detail',
        },
        {
          name: 'authlist',
          icon: 'smile',
          path: '/doctor/auth-list',
          component: './doctor/authList',
        },
        {
          name: 'authdetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/doctor/auth-detail',
          component: './doctor/auth-detail',
        },
      ],
    },
    {
      path: '/content',
      icon: 'profile',
      name: 'content',
      routes: [
        {
          path: '/content',
          redirect: '/content/doctor-creation',
        },
        {
          name: 'doctor-creation',
          icon: 'smile',
          path: '/content/doctor-creation-manager',
          component: './content/doctor-creation-manager',
        },
        {
          name: 'doctor-creation',
          icon: 'smile',
          path: '/content/doctor-creation',
          component: './content/doctor-creation',
        },
        {
          name: 'doctor-science-detail',
          icon: 'smile',
          path: '/content/science-detail',
          hideInMenu: true,
          component: './content/science-detail',
          parentKeys: ['/content/doctor-creation-manager'],
        },
        {
          name: 'doctor-creation-detail',
          icon: 'smile',
          path: '/content/doctor-creation-detail',
          hideInMenu: true,
          component: './content/detail',
          parentKeys: ['/content/doctor-creation'],
        },
        {
          name: 'creation-edit-detail',
          icon: 'smile',
          path: '/content/creation-edit-detail',
          hideInMenu: true,
          component: './content/editDetail',
          parentKeys: ['/content/doctor-creation'],
        }
      ],
    },
    {
      path: '/hospital',
      icon: 'profile',
      name: 'hospital',
      routes: [
        {
          path: '/hospital',
          redirect: '/hospital/hospital-list',
        },
        {
          name: 'list',
          icon: 'smile',
          path: '/hospital/hospital-list',
          component: './hospital/index',
        },
        {
          name: 'authlist',
          icon: 'smile',
          path: '/hospital/authList',
          component: './hospital/authList',
        },
        {
          name: 'detail',
          icon: 'smile',
          hideInMenu: true,
          path: '/hospital/hospital-detail',
          parentKeys: ['/hospital/hospital-list'],
          component: './hospital/detail',
        },
        {
          name: 'hospital.hospitalDeptList',
          icon: 'smile',
          path: '/hospital/dept-list',
          component: './hospitalDept/list',
        },
        {
          name: 'hospital.hospitalDeptList',
          icon: 'smile',
          path: '/hospital/hospitalDept-list',
          component: './hospitalDept/index',
        },
        {
          name: 'hospital.hospitalDeptDetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/hospital/hospitalDept-detail',
          component: './hospitalDept/detail',
          parentKeys: ['/hospital/hospitalDept-list'],
        },
        {
          name: 'hospitalDeptDetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/hospital/dept-detail',
          component: './hospitalDept/dept-detail',
          parentKeys: ['/hospital/dept-list'],
        },
        {
          name: 'hospitalNoticeList',
          icon: 'smile',
          path: '/hospital/hospitalNotice-list',
          component: './hospitalNotice/index',
        },
        {
          name: 'hospitalNoticeDetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/hospital/hospitalNotice-detail',
          component: './hospitalNotice/detail',
          parentKeys: ['/hospital/hospitalNotice-list'],
        },
        {
          name: 'science-detail',
          icon: 'smile',
          path: '/hospital/science-detail',
          hideInMenu: true,
          component: './hospitalNotice/science-detail',
          parentKeys: ['/hospital/hospitalNotice-list'],
        },
        {
          name: 'authdetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/hospital/auth-detail',
          parentKeys: ['/hospital/authList'],
          component: './hospital/auth-detail',
        },
      ],
    },
    {
      path: '/disease',
      name: 'disease',
      icon: 'profile',
      routes: [
        {
          path: '/disease',
          redirect: '/disease/disease-list',
        },
        {
          name: 'list',
          icon: 'smile',
          path: '/disease/disease-list',
          component: './disease/index',
        },
        {
          name: 'detail',
          icon: 'smile',
          hideInMenu: true,
          path: '/disease/disease-detail',
          component: './disease/detail',
          parentKeys: ['/disease/disease-list'],
        },
      ],
    },
    {
      path: '/case',
      name: 'case',
      icon: 'profile',
      routes: [
        {
          path: '/case',
          redirect: '/case/case-list',
        },
        {
          name: 'list',
          icon: 'smile',
          path: '/case/case-list',
          component: './case/index',
        },
        {
          name: 'detail',
          icon: 'smile',
          hideInMenu: true,
          path: '/case/case-detail',
          component: './case/detail',
          parentKeys: ['/case/case-list'],
        },
        {
          name: 'recordDetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/case/record-detail',
          component: './case/record-detail',
          parentKeys: ['/case/case-list'],
        },
        {
          name: 'records',
          icon: 'smile',
          path: '/case/records-list',
          component: './caseRecords/index',
        },
        {
          name: 'recordsDetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/case/records-detail',
          component: './case/record-detail',
          parentKeys: ['/case/records-list'],
        },
        {
          name: 'caselist',
          icon: 'smile',
          path: '/case/case-new-list',
          component: './case/list',
        },
        {
          name: 'caseDetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/case/case-detail-new',
          component: './case/case-detail-new',
          parentKeys: ['/case/records-list', '/case/case-new-list'],
        },
      ],
    },
    {
      path: '/experience',
      name: 'experience',
      icon: 'profile',
      routes: [
        {
          path: '/experience',
          redirect: '/experience/experience-list',
        },
        {
          name: 'list',
          icon: 'smile',
          path: '/experience/experience-list',
          component: './experience/index',
        },
        {
          name: 'detail',
          icon: 'smile',
          hideInMenu: true,
          path: '/experience/experience-detail',
          component: './experience/detail',
          parentKeys: ['/experience/experience-list'],
        },
      ],
    },
    {
      path: '/publish',
      name: 'publish',
      icon: 'profile',
      routes: [
        {
          path: '/publish',
          redirect: '/publish/science',
        },
        {
          name: 'science',
          icon: 'smile',
          path: '/publish/science',
          component: './science/index',
        },
        {
          name: 'sciencedetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/publish/sciencedetail',
          component: './science/science-detail',
          parentKeys: ['/publish/science'],
        },
        {
          name: 'dynamic',
          icon: 'smile',
          path: '/publish/dynamic',
          component: './dynamic/index',
        },
        {
          name: 'dynamicdetail',
          icon: 'smile',
          hideInMenu: true,
          path: '/publish/dynamicdetail',
          component: './dynamic/dynamic-detail',
          parentKeys: ['/publish/dynamic'],
        },
      ],
    },
    // {
    //   path: '/science',
    //   name: 'science',
    //   icon: 'profile',
    //   routes: [
    //     {
    //       path: '/science',
    //       redirect: '/science/list',
    //     },
    //     {
    //       name: 'list',
    //       icon: 'smile',
    //       path: '/science/list',
    //       component: './science/index',
    //     },
    //     {
    //       name: 'detail',
    //       icon: 'smile',
    //       hideInMenu: true,
    //       path: '/science/science-detail',
    //       component: './science/science-detail',
    //       parentKeys: ['/science/list'],
    //     },
    //   ],
    // },
    // {
    //   path: '/dynamic',
    //   name: 'dynamic',
    //   icon: 'profile',
    //   routes: [
    //     {
    //       path: '/dynamic',
    //       redirect: '/dynamic/list',
    //     },
    //     {
    //       name: 'list',
    //       icon: 'smile',
    //       path: '/dynamic/list',
    //       component: './dynamic/index',
    //     },
    //     {
    //       name: 'detail',
    //       icon: 'smile',
    //       hideInMenu: true,
    //       path: '/dynamic/dynamic-detail',
    //       component: './dynamic/dynamic-detail',
    //       parentKeys: ['/dynamic/list'],
    //     },
    //   ],
    // },
    {
      path: '/qaa',
      name: 'qaa',
      icon: 'profile',
      routes: [
        {
          path: '/qaa',
          redirect: '/qaa/qaa-list',
        },
        {
          name: 'list',
          icon: 'smile',
          path: '/qaa/qaa-list',
          component: './qaa/index',
        },
        {
          name: 'detail',
          icon: 'smile',
          hideInMenu: true,
          path: '/qaa/qaa-detail',
          component: './qaa/detail',
          parentKeys: ['/qaa/qaa-list'],
        },
      ],
    },
    {
      path: '/article',
      name: 'article',
      icon: 'profile',
      routes: [
        {
          path: '/article',
          redirect: '/article/article-list',
        },
        {
          name: 'list',
          icon: 'smile',
          path: '/article/article-list',
          component: './article/index',
        },
        {
          name: 'detail',
          icon: 'smile',
          hideInMenu: true,
          path: '/article/article-detail',
          component: './article/detail',
          parentKeys: ['/article/article-list'],
        },
      ],
    },
    {
      path: '/activity',
      name: 'activity',
      icon: 'profile',
      routes: [
        {
          path: '/activity',
          redirect: '/activity/activity-list',
        },
        {
          name: 'list',
          icon: 'smile',
          path: '/activity/activity-list',
          component: './activity/index',
        },
        {
          name: 'detail',
          icon: 'smile',
          hideInMenu: true,
          path: '/activity/activity-detail',
          component: './activity/detail',
          parentKeys: ['/activity/activity-list'],
        },
      ],
    },
    {
      path: '/dict',
      name: 'dict',
      icon: 'profile',
      component: './dict',
    },
    {
      path: '/subscriber',
      name: 'subscriber',
      icon: 'profile',
      routes: [
        {
          path: '/subscriber',
          redirect: '/subscriber/subscriber-list',
        },
        {
          name: 'list',
          icon: 'smile',
          path: '/subscriber/subscriber-list',
          component: './subscriber/index',
        },
        {
          name: 'detail',
          icon: 'smile',
          hideInMenu: true,
          path: '/subscriber/subscriber-detail',
          component: './subscriber/detail',
          parentKeys: ['/subscriber/subscriber-list'],
        },
        {
          name: 'userVisitor',
          hideInMenu: true,
          path: '/subscriber/userVisitor',
          component: './subscriber/userVisitor',
          parentKeys: ['/subscriber/subscriber-list'],
        },
      ],
    },
    {
      name: 'result',
      icon: 'CheckCircleOutlined',
      path: '/result',
      hideInMenu: true,
      routes: [
        {
          path: '/result',
          redirect: '/result/success',
        },
        {
          name: 'success',
          icon: 'smile',
          path: '/result/success',
          component: './result/success',
        },
        {
          name: 'fail',
          icon: 'smile',
          path: '/result/fail',
          component: './result/fail',
        },
      ],
    },
    {
      name: 'exception',
      icon: 'warning',
      hideInMenu: true,
      path: '/exception',
      routes: [
        {
          path: '/exception',
          redirect: '/exception/403',
        },
        {
          name: '403',
          icon: 'smile',
          path: '/exception/403',
          component: './exception/403',
        },
        {
          name: '404',
          icon: 'smile',
          path: '/exception/404',
          component: './exception/404',
        },
        {
          name: '500',
          icon: 'smile',
          path: '/exception/500',
          component: './exception/500',
        },
      ],
    },
    {
      path: '/setting',
      name: 'setting',
      icon: 'profile',
      routes: [
        {
          path: '/setting',
          redirect: '/setting/hospital',
        },
        {
          name: 'hospital',
          icon: 'smile',
          path: '/setting/hospital',
          component: './setting/hospital-detail',
        },
        {
          name: 'accountSettings',
          icon: 'smile',
          path: '/setting/account',
          component: './setting/account',
        }
      ],
    },
    {
      name: 'account',
      icon: 'user',
      hideInMenu: true,
      path: '/account',
      routes: [
        {
          path: '/account',
          redirect: '/account/center',
        },
        {
          name: 'center',
          icon: 'smile',
          path: '/account/center',
          component: './account/center',
        },
        {
          name: 'settings',
          icon: 'smile',
          path: '/account/settings',
          component: './account/settings',
        },
      ],
    },
    {
      name: 'editor',
      icon: 'highlight',
      hideInMenu: true,
      path: '/editor',
      routes: [
        {
          path: '/editor',
          redirect: '/editor/flow',
        },
        {
          name: 'flow',
          icon: 'smile',
          path: '/editor/flow',
          component: './editor/flow',
        },
        {
          name: 'mind',
          icon: 'smile',
          path: '/editor/mind',
          component: './editor/mind',
        },
        {
          name: 'koni',
          icon: 'smile',
          path: '/editor/koni',
          component: './editor/koni',
        },
      ],
    },
    {
      path: '/',
      redirect: '/welcome',
    },
    {
      component: '404',
    },
  ],
  access: {},
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // 如果不想要 configProvide 动态设置主题需要把这个设置为 default
    // 只有设置为 variable， 才能使用 configProvide 动态设置主色调
    // https://ant.design/docs/react/customize-theme-variable-cn
    'root-entry-name': 'variable',
  },
  // esbuild is father build tools
  // https://umijs.org/plugins/plugin-esbuild
  esbuild: {},
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
  // Fast Refresh 热更新
  fastRefresh: {},
  openAPI: [
    {
      requestLibPath: "import { request } from 'umi'",
      // 或者使用在线的版本
      // schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json"
      schemaPath: join(__dirname, 'oneapi.json'),
      mock: false,
    },
    {
      requestLibPath: "import { request } from 'umi'",
      schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json',
      projectName: 'swagger',
    },
  ],
  nodeModulesTransform: {
    type: 'none',
  },
  mfsu: {},
  webpack5: {},
  exportStatic: {},
});
